import Cookies from 'js-cookie'
import { aesStr, unAesStr } from './encryptutil';


const key = "learning_token";

/**
 * 设置token
 * @param token 
 */
export const set_token = (token: string) => {
    Cookies.set(key, aesStr(token));
}


/**
 * 获取token
 * @returns 
 */
export const get_token = () => {
    if (Cookies.get(key))
        return unAesStr(Cookies.get(key) || "");
    else
        return '';
}

/**
 * 移除token
 */
export const remove_token = () => {
    Cookies.remove(key);
}